class StorageManager {
    get<T>(key: string): T {
        try {
            const item = localStorage.getItem(key);
            if (!item) {
                return {} as T
            }
            try {
                const data = JSON.parse(item);
                return data as T;
            } catch {
                return {} as T
            }
        } catch {
            return {} as T
        }
    }
    getString(key: string): string {
        const item = localStorage.getItem(key);
        if (!item) {
            return ""
        }
        return item;
    }
    set(key: string, value: string | object) {
        if (typeof value === "string") {
            localStorage.setItem(key, value);
        } else {
            localStorage.setItem(key, JSON.stringify(value));
        }
    }
    clear() {
        localStorage.clear();
    }
    remove(key: string) {
        localStorage.removeItem(key)
    }
}

const StoreManager = new StorageManager();
export default StoreManager;